﻿using System.Collections.Generic;
using JetBrains.Annotations;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.Domain.Entities;

namespace ParkManagement
{
    /// <summary>
    /// 车辆类
    /// </summary>
    public class Car : BasicAggregateRoot<int>
    {
        /// <summary>用户编号</summary>
        public int UserId { get; protected set; }

        /// <summary>车牌号</summary>
        public string PlateNo { get; protected set; }

        /// <summary>车型</summary>
        public CarType? Type { get; protected set; }

        /// <summary>里程集合</summary>
        public IList<Consumption> Consumptions { get; protected set; }

        private Car() { }

        internal Car(
            int userId,
            string plateNo,
            CarType? type)
        {
            UserId = userId;
            PlateNo = Check.NotNullOrWhiteSpace(plateNo, nameof(plateNo));
            Type = type;
        }

        // 设置车牌号
        public Car SetPlateNo([NotNull] string plateNo)
        {
            PlateNo = Check.NotNullOrWhiteSpace(plateNo, nameof(plateNo));
            return this;
        }

        // 设置车型
        public Car SetType(CarType? type)
        {
            Type = type;
            return this;
        }
    }
}